import {
	TabViewPanelActionType,
	ICtrlEvent,
	ITabViewPanelAbility,
	ITabViewPanelControllerParams,
	ITabViewPanelModel,
	ITabViewPanelStore,
	IParam,
} from '@/core';
import { QXEvent } from 'qx-util';
import {
	getCtrlClassNames,
    handleCtrlAction,
    handleCtrlInit,
	useCtrlAction,
    handleCtrlDestroy,
	useCtrlBasic,
	useCtrlControllerParams,
	useCtrlProps,
} from '../use-ctrl';

/**
 * 分页视图面板输入参数
 *
 * @export
 * @return {*}
 */
export function useTabViewPanelProps() {
	return {
		...useCtrlProps(),
	};
}

/**
 * 分页视图面板基础参数
 *
 * @export
 * @param {ITabViewPanelModel} model
 * @param {IParam} props
 * @return {*}
 */
export function useTabViewPanelBasic(model: ITabViewPanelModel, props: IParam) {
	const getClassNames = (props: IParam) => {
		const names = getCtrlClassNames(model, props);
		return names;
	};
	return {
		...useCtrlBasic(model, props),
		getClassNames,
        handleCtrlDestroy, 
        handleCtrlInit, 
        handleCtrlAction,
	};
}

/**
 * 分页视图面板部件行为
 *
 * @export
 */
export function useTabViewPanelAction(controller: any) {
	return {
		...useCtrlAction(controller),
	};
}

/**
 * 分页视图面板部件控制器
 *
 * @export
 */
export function useTabViewPanelControllerParams<
	S extends ITabViewPanelStore,
	M extends ITabViewPanelModel
>(
	model: M,
	props: any,
	evt: QXEvent<ICtrlEvent<TabViewPanelActionType, ITabViewPanelAbility>>,
    otherParams: IParam = {},
): ITabViewPanelControllerParams<TabViewPanelActionType, ITabViewPanelAbility> {
	return {
		...useCtrlControllerParams<S, M>(model, props, evt, otherParams),
	};
}
